package com.atguigu.state.money;

import com.atguigu.state.money.allState.PublishState;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:
 * @create: 2022-03-31 17:30
 **/
public class Client {
    public static void main(String[] args) {
        //创建context 对象
        Context context = new Context();
        //将当前状态设置为 PublishState
        context.setState(new PublishState());
        System.out.println("当前状态：" + context.getCurrentState());

        //publish --> not pay
        context.acceptOrderEvent(context);
        //not pay --> paid
        context.payOrderEvent(context);

        //失败，检测失败时会抛出异常
        try {
            context.checkFailEvent(context);
            System.out.println("流程正常。。。");
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}
